package com.simtek.simplayer.entry;

import java.util.HashMap;

public class YoutubeUrlMeta extends VideoPlayEntry implements
		Comparable<YoutubeUrlMeta> {

	public static final int	QUALITY_LOW		= 0;
	public static final int	QUALITY_MEDIUM	= 1;
	public static final int	QUALITY_HIGH	= 2;

	public String			urlId;
	public int				quality;
	public String			extention;
	public int				width;
	public int				height;

	YoutubeUrlMeta(String num, String ext, int type, int w, int h) {
		this.srcType = TYPE_VIDEO_YOUTUBE;
		this.urlId = num;

		this.extention = ext;
		this.quality = type;
		this.width = w;
		this.height = h;
	}

	@Override
	public int compareTo(YoutubeUrlMeta another) {
		int res = height - another.height;
		if (res == 0) {
			return quality - another.quality;
		}
		return res;
	}

	public static HashMap<String, YoutubeUrlMeta> getMetaMap() {
		HashMap<String, YoutubeUrlMeta> typeMap = new HashMap<String, YoutubeUrlMeta>();

		typeMap.put("5", new YoutubeUrlMeta("5", "FLV", QUALITY_LOW, 400, 226));
		typeMap.put("6", new YoutubeUrlMeta("6", "FLV", QUALITY_MEDIUM, 640,
				360));
		typeMap.put("13",
				new YoutubeUrlMeta("13", "3GP", QUALITY_LOW, 176, 144));
		typeMap.put("17", new YoutubeUrlMeta("17", "3GP", QUALITY_MEDIUM, 176,
				144));
		typeMap.put("18", new YoutubeUrlMeta("18", "MP4", QUALITY_MEDIUM, 480,
				360));
		typeMap.put("22", new YoutubeUrlMeta("22", "MP4", QUALITY_HIGH, 1280,
				720));
		typeMap.put("33", new YoutubeUrlMeta("38", "MP4", QUALITY_HIGH, 4096,
				230));
		typeMap.put("34", new YoutubeUrlMeta("34", "FLV", QUALITY_MEDIUM, 640,
				360));
		typeMap.put("35", new YoutubeUrlMeta("35", "FLV", QUALITY_HIGH, 854,
				480));
		typeMap.put("36", new YoutubeUrlMeta("36", "3GP", QUALITY_HIGH, 320,
				240));
		typeMap.put("37", new YoutubeUrlMeta("37", "MP4", QUALITY_HIGH, 1920,
				1080));
		typeMap.put("43", new YoutubeUrlMeta("43", "WEBM", QUALITY_LOW, 640,
				360));
		typeMap.put("44", new YoutubeUrlMeta("44", "WEBM", QUALITY_MEDIUM, 854,
				480));
		typeMap.put("45", new YoutubeUrlMeta("45", "WEBM", QUALITY_HIGH, 1280,
				720));

		return typeMap;
	}

	public String getExtention() {
		return extention.toLowerCase();
	}
}